package web.directories.action;

import com.opensymphony.xwork2.ActionSupport;
import domain.entities.MiembroBms;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.ResultPath;
import org.springframework.beans.factory.annotation.Autowired;
import services.user.UserServicesImpl;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Guillermo
 * Date: 31/08/12
 * Time: 10:31
 * To change this template use File | Settings | File Templates.
 */
@ResultPath("/")
public class UserController  extends ActionSupport {

    private UserServicesImpl userService;
    private List<MiembroBms> users = new ArrayList<MiembroBms>();
    private String userName;
    private Integer roleid;

    @Autowired
    public UserController(UserServicesImpl userService) {
        this.userService = userService;
    }

    @Action(value="getUserByName", results={@Result(name="success",location="WEB-INF/jsp/Protocols/staffbms/userList.jsp")})
    public String execute() {
        users = userService.findByNameRoleId(userName);
        userName = "pepe";
        return SUCCESS;
    }

    public List<MiembroBms> getUsers() {
        return users;
    }

    public void setUsers(List<MiembroBms> users) {
        this.users = users;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public Integer getRoleid() {
        return roleid;
    }

    public void setRoleid(Integer roleid) {
        this.roleid = roleid;
    }
}
